﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsServerSolutions.Common.UI.TaskDialog;

namespace TV4Home.Server.Vail.AddIn.TabPageControls
{
    public partial class StatusTabUserControl : UserControl
    {
        public StatusTabUserControl()
        {
            InitializeComponent();
        }

        private void btnSetupTV_Click(object sender, EventArgs e)
        {
            if (Utils.ComponentVerifier.CheckTVServer().Status == Utils.ComponentVerifier.VerificationStatus.NotInstalled)
            {
                TaskMessageBox.Show("MediaPortal TV Server is not installed on the server. Please install it and then try again.",
                                    "Information",
                                    "MediaPortal TV Server is not installed",
                                    TaskDialogButtons.Ok,
                                    TaskDialogIcon.Information);
                return;
            }

            try
            {
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(Utils.CommonPaths.TVServer_SetupTvEXEPath) { WorkingDirectory = Utils.CommonPaths.TVServer_InstallDirectory });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }

        private void btnCheckForUpdates_Click(object sender, EventArgs e)
        {
            try
            {
                new CheckForUpdatesForm().ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }

        private void btnAbout_Click(object sender, EventArgs e)
        {
            try
            {
                new AboutForm().ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }

        private void btnReportBug_Click(object sender, EventArgs e)
        {
            try
            {
                new BugReportForm().ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace );
            }
        }
    }
}
